package com.woniu.adopt.service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.adopt.entity.ViewPage;
import com.woniu.adopt.mapper.ViewPageMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ViewPageService {
    @Autowired
    private ViewPageMapper viewPageMapper;

    public PageInfo<ViewPage> queryByPage(Integer now, Integer size,String title){
        PageHelper.startPage(now,size);
        List<ViewPage> viewPages=viewPageMapper.selectAll(title);
        return new PageInfo<>(viewPages);
    }

    public ViewPage queryPetByKey(Integer id){
        return viewPageMapper.selectByPrimaryKey(id);
    }

    public int add(ViewPage pet){
        return viewPageMapper.insert(pet);
    }

    public int removeByKey(Integer id){
        return viewPageMapper.deleteByPrimaryKey(id);
    }

    public int modify(ViewPage pet){
        return viewPageMapper.updateByPrimaryKey(pet);
    }
}
